﻿/**
   @class  
   @package
   @author Colin Leung
   @codehint 
   @example 
   @tooltip 
*/


class com.mixmedia.utils.Tools {
	static function randomRange(minVal:Number,maxVal:Number){
		return Math.random()*(maxVal-minVal)+minVal;
	};

	static function urlPath(mc:MovieClip):String{
		//getPath
		var urlPath = String(mc._url).split("/");
		var fileName = urlPath.pop();
		var filePath = urlPath.join("/");
		return filePath;
	}

	static function alignCenter(fixMc:MovieClip,floatMc:MovieClip):Void{
		var fixMcCenterX = fixMc._width/2;
		var fixMcCenterY = fixMc._height/2;
		floatMc._x = fixMc._width/2-floatMc._width + floatMc._width/2;
		floatMc._y = fixMc._height/2-floatMc._height + floatMc._height/2;
	};

	static function alignRight(fixMc:MovieClip,floatMc:MovieClip):Void{
		floatMc._x = fixMc._width - floatMc._width;
	};

	static function copy2DArray(array:Array):Array{
		var a = [];
		for (var i=0; i< array.length; i++) a[i] = array[i].slice();
		return a;
	};
	
	static function shuffleArray(oArray:Array){
		var nLength,nRandom,temp,i;
		nLength = oArray.length;
		for (i = 0; i < nLength; i++) {
			nRandom = Math.floor(Math.random()*nLength);
			temp = oArray[i];
			oArray[i] = oArray[nRandom];
			oArray[nRandom] = temp;
		}
	};
	
	static public var debugEnable:Boolean = true;
	static public function printf(arg){
		if(debugEnable)trace(arg);
	}
	

}
